package solved;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	preface
*/
public class preface {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("preface.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"preface.out")));
		new preface().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private ArrayList<Roman> rep;
	private char[] base = new char[]{'I', 'V', 'X', 'L', 'C', 'D', 'M'};
	
	public preface() {
		rep = new ArrayList<Roman>();
		rep.add(new Roman(1, "I"));
		rep.add(new Roman(4, "IV"));
		rep.add(new Roman(5, "V"));
		rep.add(new Roman(9, "IX"));
		rep.add(new Roman(10, "X"));
		rep.add(new Roman(40, "XL"));
//		rep.add(new Roman(45, "VL"));
		rep.add(new Roman(50, "L"));
		rep.add(new Roman(90, "XC"));
		rep.add(new Roman(100, "C"));
		rep.add(new Roman(400, "CD"));
//		rep.add(new Roman(450, "LD"));
		rep.add(new Roman(500, "D"));
		rep.add(new Roman(900, "CM"));
		rep.add(new Roman(1000, "M"));
		rep.add(new Roman(5000, "V'"));		
	}
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int N = read(f);
		HashMap<Character, Integer> count = new HashMap<Character, Integer>();
		for (int i=1; i<=N; i++) {
			String rep = toRoman(i);
			for (char c : rep.toCharArray()) {
				int t = count.containsKey(c)? count.get(c) : 0;
				count.put(c, t+1);
			}
		}
		
		for (char c : base) {
			if (count.containsKey(c)) {
				out.println(c + " " + count.get(c));
			}
		}
	}
	
	private String toRoman(int n) {
		if (n == 0) return "";
		for (int i=rep.size()-1; i>=0; i--) {
			Roman r = rep.get(i);
			if (n >= r.value) return r.str + toRoman(n - r.value);
		}
		return "";
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
	
	private class Roman {
		String str;
		int value;
		public Roman(int value, String str) {
			this.str = str;
			this.value = value;
		}
	}
}
